import { CommResType } from '@/types/data'
import { ArticleAction } from '@/types/store'
type CommTy = CommResType
// 用户信息的reducer
function comm (state: CommTy = {} as CommResType, action: ArticleAction) {
  switch (action.type) {
    // 存储 用户信息
    case 'article/Comm':
      return action.payload
    case 'load/Comm':
      const _old = state.results
      return {
        ...action.payload,
        results: [..._old, ...action.payload.results]
      }
    case 'add/load/Comm':
      return { ...state, results: [action.payload, ...state.results] }
    default:
      return state
  }
}

export default comm
